
beans={}
def bean(id):
    def wrapper(cls):
         def inner(*args, **kwargs):
               if id not in beans:
                   # 只在第一次调用时创建实例并存储到 beans 中
                   instance = cls(*args, **kwargs)
                   beans[id] = instance
               return beans[id]
         return inner
    return wrapper